﻿package chapter_04_Homework;

public class Work_09_Master {
	private String name="";
	private int money=0;
	/**
	 * 有参构造方法
	 * @param name 主人名字
	 * @param mongey 元宝数
	 */
	public Work_09_Master(String name,int money) {
		this.name=name;
		this.money=money;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	public void setMoney(int money) {
		this.money=money;
	}
	public int getMoney() {
		return money;
	}
	/**
	 * 主人给宠物喂食
	 */
	public void feed(Work_09_Pet pet){
		pet.eat();
	}
	
	/**
	 * 主人领养宠物
	 * @param typeId 宠物编号
	 * @return
	 */
	public Work_09_Pet getPet(int typeId){
		Work_09_Pet pet=null;
		if(typeId==1){
			pet=new Work_09_Dog("欧欧","雪纳瑞");
			
		}else if(typeId==2){
			pet=new Work_09_Penguin("楠楠","Q妹");
		}
		return pet;
	}
	/**
	 * 主人与宠物玩耍
	 */
	public void play(Work_09_Pet pet){
		if(pet instanceof Work_09_Dog){
			Work_09_Dog dog =(Work_09_Dog)pet;
			dog.catchFlyDisc();
		}else if(pet instanceof Work_09_Penguin){
			Work_09_Penguin pgn=(Work_09_Penguin)pet;
			pgn.swimming();
		}
	}
}
